#include <iostream>
#include <ctime>
#include "Task.hpp"
#include "ThreadPool.hpp"

int main()
{
    std::cout << "Sigleton Run ..." << std::endl;
    sleep(3);
    //ThreadPool<Task>* tp = new ThreadPool<Task>();
    ThreadPool<Task>::GetInstance()->Start();
    srand(time(nullptr) ^ getpid());
    while(true)
    {
        //1、构建任务
        int x = rand() % 10 + 1;
        usleep(6);
        int y = rand() % 5;
        char op = OP[rand() % OP.size()];

        Task t(x,y,op);
        //2、交给线程池处理
        ThreadPool<Task>::GetInstance()->Push(t);
        std::cout << "main thread make task" << t.GetTask()<< std::endl;
        sleep(1);
    }

    return 0;
}